JBoss Community Archive (Read Only)

Teiid 8.3

Type Conversions

Data types may be converted from one form to another either explicitly or implicitly. Implicit conversions automatically occur in criteria and expressions to ease development. Explicit datatype conversions require the use of the CONVERT function or CAST keyword.

Type Conversion Considerations

For example:

SELECT * FROM my.table WHERE created_by = ‘not a date’

Given that created_by is typed as date, rather than converting 'not a date' to a date value, the criteria will remain as a string comparison and therefore be false.

Warning

The Teiid conversions of float/double/bigdecimal/timestamp to string rely on the JDBC/Java defined output formats. Pushdown behavior attempts to mimic these results, but may vary depending upon the actual source type and conversion logic. Care should be taken to not assume the string form in criteria or other places where a variation may cause different results.

<scroll-title title="Type Conversions"></scroll-title>

Source Type

Valid Implicit Target Types

Valid Explicit Target Types

string

clob

char, boolean, byte, short, integer, long, biginteger, float, double, bigdecimal, xml [a]

char

string

 

boolean

string, byte, short, integer, long, biginteger, float, double, bigdecimal

 

byte

string, short, integer, long, biginteger, float, double, bigdecimal

boolean

short

string, integer, long, biginteger, float, double, bigdecimal

boolean, byte

integer

string, long, biginteger, double, bigdecimal

boolean, byte, short, float

long

string, biginteger, bigdecimal

boolean, byte, short, integer, float, double

biginteger

string, bigdecimal

boolean, byte, short, integer, long, float, double

bigdecimal

string

boolean, byte, short, integer, long, biginteger, float, double

date

string, timestamp

 

time

string, timestamp

 

timestamp

string

date, time

clob

 

string

xml

 

string [b]

[a] string to xml is equivlant to XMLPARSE(DOCUMENT exp) - See also XML Functions#XMLPARSE
[b] xml to string is equivalent to XMLSERIALIZE(exp AS STRING) - see also XML Functions#XMLSERIALIZE

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 12:38:19 UTC, last content change 2013-03-14 16:27:44 UTC.